import rsa
import pickle

# 生成公钥和私钥
(public_key, private_key) = rsa.newkeys(512)

# 将公钥和私钥保存到文件
with open('public_key.pem', 'wb') as f_pub:
    pickle.dump(public_key, f_pub)

with open('private_key.pem', 'wb') as f_priv:
    pickle.dump(private_key, f_priv)
  